package com.unitechs.appbiz.web.controller;

import com.unitechs.appbiz.constant.AppApiURL;
import com.unitechs.appbiz.constant.CommonConstants;
import com.unitechs.appbiz.domain.service.AppService;
import com.unitechs.framework.rest.bean.RestResponse;
import com.unitechs.framework.rest.controller.BaseRestController;
import com.unitechs.orch.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 电路管理Controller
 *
 * @author wenzy
 * @since 2021/05/13
 */
@Slf4j
@Api(tags = "app管理API")
@RestController
public class AppController extends BaseRestController {

    /**
     * app管理service
     */
    @Autowired
    private AppService appService;

    /**
     * 2.4.2 app版本检测更新
     *
     * @return RestResponse response
     */
    @ApiOperation(value = "2.4.2 app版本检测更新")
    @PostMapping(value = AppApiURL.VERSION_CHECK)
    public RestResponse versionCheck() {
        logger.info("versionCheck starts... {}");

        try {
            //参数校验
            System.out.println("ces");
            System.out.println("ces");
            System.out.println("ces2222222");

            //具体操作 与 返回
            return appService.versionCheck();

        } catch (ServiceException se) {
            return RestResponse.addError(CommonConstants.ERROR_CODE, se.getMessage());
        } catch (Exception e) {
            //e.printStackTrace();
            logger.error("versionCheck：", e);
            return RestResponse.addError(CommonConstants.ERROR_CODE, e.getMessage());
        }
    }

}
